﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.IO;
using System.Text;
using Royalsoft.Common;
using System.Web.Script.Services;

namespace NJL.WebMembers
{
    /// <summary>
    /// WebService 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
    [System.Web.Script.Services.ScriptService]
    public class WebService : System.Web.Services.WebService
    {
        BasePageVisitor basepage = new BasePageVisitor();

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";

        }
        /// <summary>
        /// 个人首页列表
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        [WebMethod(Description = "分页获取个人首页列表")]
        public News GetNewsListStr(int pageSize, int pageIndex)
        {
            NJL.BLL.NJL_SYS_BASE bllArea = new BLL.NJL_SYS_BASE();
            NJL.Model.NJL_SYS_BASE modelArea;
            NJL.BLL.NJL_NEWS bllNews = new BLL.NJL_NEWS();
            DataSet ds = bllNews.GetListPage(pageSize, pageIndex, "");
            StringBuilder strBuilder = new StringBuilder();
            NJL.BLL.NJL_NEWS_COMMENT bllNewsComment = new BLL.NJL_NEWS_COMMENT();

            try
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    object objcount = bllNewsComment.GetListCount("NJL_NEWS_ID='" + row["ID"] + "'");
                    modelArea = bllArea.GetModel(row["NJL_SYS_BASE_ID"].ToString());
                    using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Trip_List_Item.html")))
                    {
                        string str = strReader.ReadToEnd();
                        str = str.Replace("{$UserImage$}", row["IMAGE_CODE1"].ToString() != "" ? BasePageVisitor.GetImageUrl(row["IMAGE_CODE1"].ToString(), "U2") : "/Images/avatar.jpg");
                        str = str.Replace("{$UserName$}", row["CREATE_USER_NAME"].ToString());
                        str = str.Replace("{$Title$}", PageValidate.SqlText(row["NEWS_TITLE"].ToString(), 15));
                        str = str.Replace("{$Content$}", PageValidate.SqlText(PageValidate.DelHTML(row["NEWS_CONTECT"].ToString()), 150));
                        str = str.Replace("{$NewsImage$}", BasePageVisitor.GetImageUrl(row["IMAGE_CODE"].ToString(), "C1"));
                        str = str.Replace("{$NewsHit$}", row["VISIT_COUNT"].ToString());
                        str = str.Replace("{$CommentHit$}", objcount.ToString());
                        str = str.Replace("{$CreatDateTime$}", string.Format("{0:yyyy-MM-dd HH:mm}", row["CREATE_DATE_TIME"]));
                        str = str.Replace("{$WebSiteName$}", modelArea.WEBSITE_NAME);
                        str = str.Replace("{$WebSiteUrl$}", modelArea.WEBSITE_DOMAIN);
                        str = str.Replace("{$IsImage$}", string.IsNullOrEmpty(row["IMAGE_CODE"].ToString()) ? "none" : "block");
                        str = str.Replace("$NewsId$", row["ID"].ToString());
                        strBuilder.Append(str);
                    }
                }
                object obj = bllNews.GetListCount("");
                int pageCount = Convert.ToInt32(obj);
                News news = new News();
                news.Content = strBuilder.ToString();
                news.PageCount = pageCount % pageSize == 0 ? pageCount / pageSize : pageCount / pageSize + 1;
                return news;
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }


        }
        /// <summary>
        /// 游记内容
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        [WebMethod(Description = "游记内容")]
        public string GetNewsContent(string newsId)
        {
            NJL.BLL.NJL_NEWS bllNews = new BLL.NJL_NEWS();
            DataSet ds = bllNews.GetNewsListInUser(1, "a.ID='" + newsId + "'", "a.CREATE_DATE_TIME desc");
            NJL.BLL.NJL_NEWS_COMMENT bllNewsComment = new BLL.NJL_NEWS_COMMENT();
            object obj = bllNewsComment.GetListCount("NJL_NEWS_ID='" + newsId + "'");
            StringBuilder strBuilder = new StringBuilder();
            try
            {
                DataRow row = ds.Tables[0].Rows[0];
                using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Trip_List_Content.html")))
                {
                    string str = strReader.ReadToEnd();
                    str = str.Replace("{$Image$}", row["IMAGE_CODE1"].ToString() != "" ? BasePageVisitor.GetImageUrl(row["IMAGE_CODE1"].ToString(), "U2") : "/Images/avatar.jpg");
                    str = str.Replace("{$ImageTitle$}", row["CREATE_USER_NAME"].ToString());
                    str = str.Replace("{$UserName$}", row["CREATE_USER_NAME"].ToString());
                    str = str.Replace("{$Title$}", row["NEWS_TITLE"].ToString());
                    str = str.Replace("{$Content$}", row["NEWS_CONTECT"].ToString());
                    str = str.Replace("{$NewsImage$}", BasePageVisitor.GetImageUrl(row["IMAGE_CODE"].ToString(), "5"));
                    str = str.Replace("{$CreateDate$}", string.Format("{0:yyyy-MM-dd HH:mm}", row["CREATE_DATE_TIME"]));
                    str = str.Replace("{$IsImage$}", string.IsNullOrEmpty(row["IMAGE_CODE"].ToString()) ? "none" : "block");
                    str = str.Replace("{$CommentHit$}", obj.ToString());
                    str = str.Replace("{$Hit$}", row["VISIT_COUNT"].ToString());
                    strBuilder.Append(str);
                }
                return strBuilder.ToString();
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }
        }
        /// <summary>
        /// 读取评论内容
        /// </summary>
        /// <param name="newsId"></param>
        /// <returns></returns>
        [WebMethod(Description = "读取首页评论内容")]
        public string GetNewsComment(string newsId)
        {
            NJL.BLL.NJL_NEWS_COMMENT bllNewsComment = new BLL.NJL_NEWS_COMMENT();
            DataSet ds = bllNewsComment.GetListInUser(100, "a.NJL_NEWS_ID='" + newsId + "'", "a.CREATE_DATE_TIME desc");
            StringBuilder strBuilder = new StringBuilder();
            try
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Trip_List_ItemComment.html")))
                    {
                        string str = strReader.ReadToEnd();
                        str = str.Replace("{$UserImage$}", row["IMAGE_CODE1"].ToString() != "" ? BasePageVisitor.GetImageUrl(row["IMAGE_CODE1"].ToString(), "U2") : "/Images/avatar.jpg");
                        str = str.Replace("{$UserName$}", row["CREATE_USER_NAME"].ToString());
                        str = str.Replace("{$CommentContent$}", row["NEWS_COMMENT"].ToString());
                        str = str.Replace("{$CreateDate$}", string.Format("{0:yyyy-MM-dd HH:mm}", row["CREATE_DATE_TIME"]));
                        strBuilder.Append(str);
                    }
                }
                return strBuilder.ToString();
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }

        }
        /// <summary>
        /// 好吃的列表
        /// </summary>
        /// <returns></returns>
        [WebMethod(Description = "好吃的列表")]
        public News EatList(int pageSize, int pageIndex)
        {
            NJL.BLL.NJL_COMPANY_SERVICE bllService = new BLL.NJL_COMPANY_SERVICE();
            DataSet ds = bllService.GetServiceInCompany(pageSize, pageIndex, " a.TYPE_CODE='1' and b.NJL_SYS_BASE_ID='" + basepage.WEBSITE_CODE + "'");
            StringBuilder strBuilder = new StringBuilder();
            NJL.BLL.NJL_SERVICE_COMMENT bllServiceComment = new BLL.NJL_SERVICE_COMMENT();
            try
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    object objCount = bllServiceComment.GetListCount("NJL_COMPANY_SERVICE_ID='" + row["ID"] + "'");
                    using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Eat_List_Item.html")))
                    {
                        string str = strReader.ReadToEnd();
                        str = str.Replace("{$ServiceImage$}", row["IMAGE_CODE"].ToString() != "" ? BasePageVisitor.GetImageUrl(row["IMAGE_CODE"].ToString(), "1") : "/Images/nopic.jpg");
                        str = str.Replace("{$ServiceName$}", row["SERVICE_NAME"].ToString());
                        str = str.Replace("{$ServiceContent$}", PageValidate.SqlText(PageValidate.DelHTML(row["SERVICE_CONTENT"].ToString()), 60));
                        str = str.Replace("{$CreateDate$}", string.Format("{0:yyyy-MM-dd HH:mm}", row["CREATE_DATE_TIME"]));
                        str = str.Replace("{$CompanyName$}", row["COMPANY_NAME"].ToString());
                        str = str.Replace("{$Tel$}", row["TEL"].ToString());
                        str = str.Replace("{$Address$}", row["ADDRESS"].ToString());
                        str = str.Replace("{$Hit$}", row["VISIT_COUNT"].ToString());
                        str = str.Replace("{$CommentCount$}", objCount.ToString());
                        str = str.Replace("{$ServiceId$}", row["ID"].ToString());
                        strBuilder.Append(str);
                    }
                }
                News eat = new News();
                object obj = bllService.GetServiceCount(" TYPE_CODE='1' and NJL_COMPANY_ID in(select ID from NJL_COMPANY where NJL_SYS_BASE_ID='" + basepage.WEBSITE_CODE + "')");
                int pageCount = Convert.ToInt32(obj);
                eat.Content = strBuilder.ToString();
                eat.PageCount = pageCount % pageSize == 0 ? pageCount / pageSize : pageCount / pageSize + 1;
                return eat;
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }

        }
        /// <summary>
        ///好吃的内容
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        [WebMethod(Description = "好吃的内容")]
        public string GetEatContent(string Id)
        {
            NJL.BLL.NJL_COMPANY bllCompany = new BLL.NJL_COMPANY();
            NJL.Model.NJL_COMPANY modelCompany;
            NJL.BLL.NJL_COMPANY_SERVICE bll = new BLL.NJL_COMPANY_SERVICE();
            NJL.Model.NJL_COMPANY_SERVICE model = bll.GetModel(Id);
            NJL.BLL.NJL_SERVICE_COMMENT bllServiceComment = new BLL.NJL_SERVICE_COMMENT();
            object objCount = bllServiceComment.GetListCount("NJL_COMPANY_SERVICE_ID='" + Id + "'");
            modelCompany = bllCompany.GetModel(model.NJL_COMPANY_ID);
            StringBuilder strBuilder = new StringBuilder();
            try
            {
                using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Eat_List_Content.html")))
                {
                    string str = strReader.ReadToEnd();
                    str = str.Replace("{$Class$}", "shichi");
                    str = str.Replace("{$ClassTitle$}", "免费试吃");
                    str = str.Replace("{$Title$}", model.SERVICE_NAME);
                    str = str.Replace("{$Content$}", model.SERVICE_CONTENT);
                    str = str.Replace("{$Image$}", !string.IsNullOrEmpty(model.IMAGE_CODE) ? BasePageVisitor.GetImageUrl(model.IMAGE_CODE, "5") : "/Images/nopic.jpg");
                    str = str.Replace("{$CreateDate$}", string.Format("{0:yyyy-MM-dd HH:mm}", model.CREATE_DATE_TIME));
                    str = str.Replace("{$CommentHit$}", objCount.ToString());
                    str = str.Replace("{$Hit$}", model.VISIT_COUNT.ToString());
                    str = str.Replace("{$CompanyName$}", modelCompany.COMPANY_NAME);
                    strBuilder.Append(str);
                }
                return strBuilder.ToString();
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }
        }
        /// <summary>
        /// 读取服务评论内容
        /// </summary>
        /// <param name="newsId"></param>
        /// <returns></returns>
        [WebMethod(Description = "读取服务评论内容")]
        public string GetEatComment(string Id)
        {
            NJL.BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
            NJL.Model.NJL_PERSON modelPerson;
            NJL.BLL.NJL_SERVICE_COMMENT bllNewsComment = new BLL.NJL_SERVICE_COMMENT();
            DataSet ds = bllNewsComment.GetList("NJL_COMPANY_SERVICE_ID='" + Id + "'");
            StringBuilder strBuilder = new StringBuilder();
            try
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    modelPerson = bllPerson.GetModelByUserId(row["CREATE_USER_ID"].ToString());
                    using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Trip_List_ItemComment.html")))
                    {
                        string str = strReader.ReadToEnd();
                        str = str.Replace("{$UserImage$}", modelPerson.IMAGE_CODE != "" ? BasePageVisitor.GetImageUrl(modelPerson.IMAGE_CODE, "U2") : "/Images/avatar.jpg");
                        str = str.Replace("{$UserName$}", row["CREATE_USER_NAME"].ToString());
                        str = str.Replace("{$CommentContent$}", row["COMMENT_CONTENT"].ToString());
                        str = str.Replace("{$CreateDate$}", string.Format("{0:yyyy-MM-dd HH:mm}", row["CREATE_DATE_TIME"]));
                        strBuilder.Append(str);
                    }
                }
                return strBuilder.ToString();
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }
        }
        /// <summary>
        /// 好玩的列表
        /// </summary>
        /// <returns></returns>
        [WebMethod(Description = "好玩的列表")]
        public News PlayList(int pageSize, int pageIndex)
        {
            NJL.BLL.NJL_COMPANY_SERVICE bllService = new BLL.NJL_COMPANY_SERVICE();
            DataSet ds = bllService.GetServiceInCompany(pageSize, pageIndex, " a.TYPE_CODE<>'1' and a.TYPE_CODE<>'2' and a.TYPE_CODE<>'20' and b.NJL_SYS_BASE_ID='" + basepage.WEBSITE_CODE + "'");
            StringBuilder strBuilder = new StringBuilder();
            NJL.BLL.NJL_SERVICE_COMMENT bllServiceComment = new BLL.NJL_SERVICE_COMMENT();
            try
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    object objCount = bllServiceComment.GetListCount("NJL_COMPANY_SERVICE_ID='" + row["ID"] + "'");
                    using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Eat_List_Item.html")))
                    {
                        string str = strReader.ReadToEnd();
                        str = str.Replace("{$ServiceImage$}", row["IMAGE_CODE"].ToString() != "" ? BasePageVisitor.GetImageUrl(row["IMAGE_CODE"].ToString(), "1") : "/Images/nopic.jpg");
                        str = str.Replace("{$ServiceName$}", row["SERVICE_NAME"].ToString());
                        str = str.Replace("{$ServiceContent$}", PageValidate.SqlText(PageValidate.DelHTML(row["SERVICE_CONTENT"].ToString()), 60));
                        str = str.Replace("{$CreateDate$}", string.Format("{0:yyyy-MM-dd HH:mm}", row["CREATE_DATE_TIME"]));
                        str = str.Replace("{$CompanyName$}", row["COMPANY_NAME"].ToString());
                        str = str.Replace("{$Tel$}", row["TEL"].ToString());
                        str = str.Replace("{$Address$}", row["ADDRESS"].ToString());
                        str = str.Replace("{$Hit$}", row["VISIT_COUNT"].ToString());
                        str = str.Replace("{$CommentCount$}", objCount.ToString());
                        str = str.Replace("{$ServiceId$}", row["ID"].ToString());
                        strBuilder.Append(str);
                    }
                }
                News eat = new News();
                object obj = bllService.GetServiceCount(" TYPE_CODE='1' and NJL_COMPANY_ID in(select ID from NJL_COMPANY where NJL_SYS_BASE_ID='" + basepage.WEBSITE_CODE + "')");
                int pageCount = Convert.ToInt32(obj);
                eat.Content = strBuilder.ToString();
                eat.PageCount = pageCount % pageSize == 0 ? pageCount / pageSize : pageCount / pageSize + 1;
                return eat;
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }

        }
        /// <summary>
        /// 买特产列表
        /// </summary>
        /// <returns></returns>
        [WebMethod(Description = "买特产列表")]
        public News LocalColorList(int pageSize, int pageIndex)
        {
            NJL.BLL.NJL_LOCAL_COLOR bllLocalColor = new BLL.NJL_LOCAL_COLOR();
            DataSet ds = bllLocalColor.GetList(pageSize, pageIndex, "NJL_SYS_BASE_ID='" + basepage.WEBSITE_CODE + "'");
            StringBuilder strBuilder = new StringBuilder();
            NJL.BLL.NJL_ATTRACTION_COMMENT bllComment = new BLL.NJL_ATTRACTION_COMMENT();
            try
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    object objCount = bllComment.GetListCount("NJL_ATTRACTION_ID='" + row["ID"] + "' and COMMENT_TYPE=2");
                    using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Shop_List_Item.html")))
                    {
                        string str = strReader.ReadToEnd();
                        str = str.Replace("{$Image$}", row["IMAGE_CODE"].ToString() != "" ? BasePageVisitor.GetImageUrl(row["IMAGE_CODE"].ToString(), "C1") : "/Images/nopic.jpg");
                        str = str.Replace("{$Title$}", PageValidate.SqlText(row["NEWS_TITLE"].ToString(), 10));
                        str = str.Replace("{$Hit$}", row["VISIT_COUNT"].ToString());
                        str = str.Replace("{$CommentHit$}", objCount.ToString());
                        str = str.Replace("{$Id$}", row["ID"].ToString());
                        str = str.Replace("{$CreateDate$", string.Format("{0:yyyy-MM-dd HH:mm}", row["CREATE_DATE_TIME"]));
                        str = str.Replace("{$WebSiteName$}", basepage.WEBSITE_NAME);
                        strBuilder.Append(str);
                    }
                }
                News eat = new News();
                object obj = bllLocalColor.GetCount("NJL_SYS_BASE_ID='" + basepage.WEBSITE_CODE + "'");
                int pageCount = Convert.ToInt32(obj);
                eat.Content = strBuilder.ToString();
                eat.PageCount = pageCount % pageSize == 0 ? pageCount / pageSize : pageCount / pageSize + 1;
                return eat;
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }

        }
        /// <summary>
        ///买特产内容
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        [WebMethod(Description = "买特产内容")]
        public string LocalColorContent(string Id)
        {
            NJL.BLL.NJL_LOCAL_COLOR bll = new BLL.NJL_LOCAL_COLOR();
            NJL.Model.NJL_LOCAL_COLOR model = bll.GetModel(Id);
            NJL.BLL.NJL_ATTRACTION_COMMENT bllComment = new BLL.NJL_ATTRACTION_COMMENT();
            object objCount = bllComment.GetListCount("NJL_ATTRACTION_ID='" + Id + "' and COMMENT_TYPE=2");
            StringBuilder strBuilder = new StringBuilder();
            try
            {
                using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Eat_List_Content.html")))
                {
                    string str = strReader.ReadToEnd();
                    str = str.Replace("{$Class$}", "dinggou");
                    str = str.Replace("{$ClassTitle$}", "立即订购");
                    str = str.Replace("{$Title$}", model.NEWS_TITLE);
                    str = str.Replace("{$Content$}", model.NEWS_CONTECT);
                    str = str.Replace("{$Image$}", !string.IsNullOrEmpty(model.IMAGE_CODE) ? BasePageVisitor.GetImageUrl(model.IMAGE_CODE, "5") : "/Images/nopic.jpg");
                    str = str.Replace("{$CreateDate$}", string.Format("{0:yyyy-MM-dd HH:mm}", model.CREATE_DATE_TIME));
                    str = str.Replace("{$CommentHit$}", objCount.ToString());
                    str = str.Replace("{$Hit$}", model.VISIT_COUNT.ToString());
                    str = str.Replace("{$CompanyName$}", basepage.WEBSITE_NAME);
                    strBuilder.Append(str);
                }
                return strBuilder.ToString();
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }
        }
        /// <summary>
        /// 买特产评论
        /// </summary>
        /// <param name="newsId"></param>
        /// <returns></returns>
        [WebMethod(Description = "买特产评论")]
        public string LocalColorComment(string Id)
        {
            NJL.BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
            NJL.Model.NJL_PERSON modelPerson;
            NJL.BLL.NJL_ATTRACTION_COMMENT bllComment = new BLL.NJL_ATTRACTION_COMMENT();
            DataSet ds = bllComment.GetList("NJL_ATTRACTION_ID='" + Id + "' and COMMENT_TYPE=2");
            StringBuilder strBuilder = new StringBuilder();
            try
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    modelPerson = bllPerson.GetModelByUserId(row["CREATE_USER_ID"].ToString());
                    using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Trip_List_ItemComment.html")))
                    {
                        string str = strReader.ReadToEnd();
                        str = str.Replace("{$UserImage$}", modelPerson.IMAGE_CODE != "" ? BasePageVisitor.GetImageUrl(modelPerson.IMAGE_CODE, "U2") : "/Images/avatar.jpg");
                        str = str.Replace("{$UserName$}", row["CREATE_USER_NAME"].ToString());
                        str = str.Replace("{$CommentContent$}", row["NEWS_COMMENT"].ToString());
                        str = str.Replace("{$CreateDate$}", string.Format("{0:yyyy-MM-dd HH:mm}", row["CREATE_DATE_TIME"]));
                        strBuilder.Append(str);
                    }
                }
                return strBuilder.ToString();
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }
        }
        /// <summary>
        /// 活动列表
        /// </summary>
        /// <returns></returns>
        [WebMethod(Description = "活动列表")]
        public News ActiveList(int pageSize, int pageIndex)
        {
            NJL.BLL.NJL_ACTIVE bll = new BLL.NJL_ACTIVE();
            DataSet ds = bll.GetList(pageSize, pageIndex, "NJL_COMPANY_ID in(select ID from NJL_COMPANY where NJL_SYS_BASE_ID='" + basepage.WEBSITE_CODE + "')");
            StringBuilder strBuilder = new StringBuilder();
            NJL.BLL.NJL_ACTIVE_COMMENT bllComment = new BLL.NJL_ACTIVE_COMMENT();
            try
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    object objCount = bllComment.GetListCount("NJL_ACTIVE_ID='" + row["ID"] + "'");
                    using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Active_List_Item.html")))
                    {
                        string str = strReader.ReadToEnd();
                        str = str.Replace("{$Image$}", row["IMAGE_CODE"].ToString() != "" ? BasePageVisitor.GetImageUrl(row["IMAGE_CODE"].ToString(), "C1") : "/Images/nopic.jpg");
                        str = str.Replace("{$IsDisPlayImg$}", string.IsNullOrEmpty(row["IMAGE_CODE"].ToString()) ? "none" : "block");
                        str = str.Replace("{$Title$}", row["ACTIVE_NAME"].ToString());
                        str = str.Replace("{$Hit$}", row["VISIT_COUNT"].ToString());
                        str = str.Replace("{$CommentHit$}", objCount.ToString());
                        str = str.Replace("{$Id$}", row["ID"].ToString());
                        str = str.Replace("{$CreateDate$", string.Format("{0:yyyy-MM-dd HH:mm}", row["CREATE_DATE_TIME"]));
                        strBuilder.Append(str);
                    }
                }
                News eat = new News();
                object obj = bll.GetListCount("NJL_COMPANY_ID in(select ID from NJL_COMPANY where NJL_SYS_BASE_ID='" + basepage.WEBSITE_CODE + "')");
                int pageCount = Convert.ToInt32(obj);
                eat.Content = strBuilder.ToString();
                eat.PageCount = pageCount % pageSize == 0 ? pageCount / pageSize : pageCount / pageSize + 1;
                return eat;
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }

        }
        /// <summary>
        ///活动内容
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        [WebMethod(Description = "活动内容")]
        public string ActiveContent(string Id)
        {
            NJL.BLL.NJL_ACTIVE bll = new BLL.NJL_ACTIVE();
            NJL.Model.NJL_ACTIVE model = bll.GetModel(Id);
            NJL.BLL.NJL_ACTIVE_COMMENT bllComment = new BLL.NJL_ACTIVE_COMMENT();
            object objCount = bllComment.GetListCount("NJL_ACTIVE_ID='" + Id + "'");
            StringBuilder strBuilder = new StringBuilder();
            NJL.BLL.NJL_COMPANY bllCompany = new BLL.NJL_COMPANY();
            NJL.Model.NJL_COMPANY modelCompany = bllCompany.GetModel(model.NJL_COMPANY_ID);
            try
            {
                using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Eat_List_Content.html")))
                {
                    string str = strReader.ReadToEnd();
                    str = str.Replace("{$Class$}", "baoming");
                    str = str.Replace("{$ClassTitle$}", "报名参加");
                    str = str.Replace("{$Title$}", model.ACTIVE_NAME);
                    str = str.Replace("{$Content$}", model.ACTIVE_CONTENT);
                    str = str.Replace("{$Image$}", !string.IsNullOrEmpty(model.IMAGE_CODE) ? BasePageVisitor.GetImageUrl(model.IMAGE_CODE, "5") : "/Images/nopic.jpg");
                    str = str.Replace("{$CreateDate$}", string.Format("{0:yyyy-MM-dd HH:mm}", model.CREATE_DATE_TIME));
                    str = str.Replace("{$CommentHit$}", objCount.ToString());
                    str = str.Replace("{$Hit$}", model.VISIT_COUNT.ToString());
                    str = str.Replace("{$CompanyName$}", modelCompany.COMPANY_NAME);
                    strBuilder.Append(str);
                }
                return strBuilder.ToString();
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }
        }
        /// <summary>
        /// 活动评论
        /// </summary>
        /// <param name="newsId"></param>
        /// <returns></returns>
        [WebMethod(Description = "活动评论")]
        public string ActiveComment(string Id)
        {
            NJL.BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
            NJL.Model.NJL_PERSON modelPerson;
            NJL.BLL.NJL_ACTIVE_COMMENT bllComment = new BLL.NJL_ACTIVE_COMMENT();
            DataSet ds = bllComment.GetList("NJL_ACTIVE_ID='" + Id + "'");
            StringBuilder strBuilder = new StringBuilder();
            try
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    modelPerson = bllPerson.GetModelByUserId(row["CREATE_USER_ID"].ToString());
                    using (StreamReader strReader = new StreamReader(Server.MapPath("~/HtmlTemplates/Trip_List_ItemComment.html")))
                    {
                        string str = strReader.ReadToEnd();
                        str = str.Replace("{$UserImage$}", modelPerson.IMAGE_CODE != "" ? BasePageVisitor.GetImageUrl(modelPerson.IMAGE_CODE, "U2") : "/Images/avatar.jpg");
                        str = str.Replace("{$UserName$}", row["CREATE_USER_NAME"].ToString());
                        str = str.Replace("{$CommentContent$}", row["COMMENT_CONTENT"].ToString());
                        str = str.Replace("{$CreateDate$}", string.Format("{0:yyyy-MM-dd HH:mm}", row["CREATE_DATE_TIME"]));
                        strBuilder.Append(str);
                    }
                }
                return strBuilder.ToString();
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("找不到模板文件哦" + e.Message);
                throw e;
            }
        }
        /// <summary>
        /// 查询已登录的用户信息
        /// </summary>
        /// <returns></returns>
        [WebMethod(Description = "查询已登录的用户信息")]
        [ScriptMethod(UseHttpGet = true)]
        public Model.NJL_USER GetUserModel()
        {
            NJL.BLL.NJL_USER bllUser = new BLL.NJL_USER();
            NJL.Model.NJL_USER model = bllUser.GetModel(basepage.UserId);
            return model;

        }
        /// <summary>
        /// 查询已登录的用户信息
        /// </summary>
        /// <returns></returns>
        [WebMethod(Description = "查询已登录的用户信息")]
        [ScriptMethod(UseHttpGet = true)]
        public Model.NJL_PERSON GetPersonModel()
        {
            NJL.BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
            NJL.Model.NJL_PERSON model = bllPerson.GetModelByUserId(basepage.UserId);
            model.IMAGE_CODE = BasePageVisitor.GetImageUrl(model.IMAGE_CODE);
            return model;
        }
        /// <summary>
        /// 查询用户爱好信息
        /// </summary>
        /// <returns></returns>
        [WebMethod(Description = "查询用户爱好信息")]
        [ScriptMethod(UseHttpGet = true)]
        public List<NJL.Model.NJL_CS_LIKES> GetLikesModel()
        {
            NJL.BLL.NJL_CS_LIKES bll = new BLL.NJL_CS_LIKES();
            return bll.GetModelList("");
        }
        /// <summary>
        /// 查询省信息
        /// </summary>
        /// <returns></returns>
        [WebMethod(Description = "查询城市信息")]
        //[ScriptMethod(UseHttpGet = true)]
        public List<NJL.Model.NJL_CS_AREA> GetAreaListModel(string strWhere)
        {
            NJL.BLL.NJL_CS_AREA bll = new BLL.NJL_CS_AREA();
            return bll.GetModelList("AREA_CODE like '" + strWhere + "'");

        }
        /// <summary>
        /// 更新用户和个人信息
        /// </summary>
        [WebMethod(Description = "更新用户和个人信息")]
        public string UpdateUserInfoAndPerson(string mobel, string tel, string qq, string msn, string userName, string realName, string sex, string birthday, string area, string education, string cardType, string cardId, string likes)
        {
            NJL.BLL.NJL_USER blllUser = new BLL.NJL_USER();
            NJL.Model.NJL_USER modelUser = blllUser.GetModel(basepage.UserId);
            modelUser.MOBILE = mobel;
            modelUser.TEL = tel;
            modelUser.QQ = qq;
            modelUser.MSN = msn;
            modelUser.USER_NAME = userName;


            NJL.BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
            NJL.Model.NJL_PERSON modelPerson = bllPerson.GetModelByUserId(basepage.UserId);
            modelPerson.REAL_NAME = realName;
            modelPerson.SEX = sex;
            DateTime datetime;
            if (DateTime.TryParse(birthday+" 00:00:00.000", out datetime))
            {
                modelPerson.BIRTHDAY = datetime;
            }
            modelPerson.AREA_CODE = area;
            modelPerson.DEGREE = education;
            modelPerson.ID_TYPE = cardType;
            modelPerson.ID_CODE = cardId;
            modelPerson.LIKES = likes;
            if (blllUser.UpdateUserAndPerson(modelUser, modelPerson))
            {
                return "true";
            }
            else
            {
                return "false";
            }

        }
        /// <summary>
        /// 列表
        /// </summary>
        public class News
        {
            /// <summary>
            /// 内容
            /// </summary>
            public string Content { get; set; }
            /// <summary>
            /// 总页数
            /// </summary>
            public int PageCount { get; set; }
        }
    }
}
